/*
 * Created on 2005-7-6
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.sohu.sip.auth.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sohu.peak.util.Logger;
import com.sohu.sip.auth.business.bean.AuthLogBean;
import com.sohu.sip.auth.business.event.AuthLogListEvent;
import com.sohu.sip.auth.business.result.AuthLogListResult;
import com.sohu.sip.auth.constant.AuthConstant;
import com.sohu.sip.auth.util.ParamUtil;

/**
 * @author luciali
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class AuthLogAction extends BaseAction {
	private static Logger log = new Logger();

	public String listAuthLog() {
		try {
			HttpServletRequest request=org.apache.struts2.ServletActionContext.getRequest();
			HttpServletResponse response=org.apache.struts2.ServletActionContext.getResponse();
			AuthLogListEvent event = new AuthLogListEvent(ParamUtil.getLowerCase(request, "username"),
					ParamUtil.getString(request, "urlPattern"),
					ParamUtil.getString(request, "beginDate"),
					ParamUtil.getString(request, "endDate"),
					ParamUtil.getInt(request, "pagination.pageNO", 1).intValue(),
					ParamUtil.getInt(request, "pageCount", AuthConstant.COUNT_PERPAGE).intValue());
			AuthLogListResult result = AuthLogBean.getInstance().list(event);
			request.setAttribute("result", result);
			request.setAttribute("pagination", result.getPagination());
			if (result.getStatus() == 0)
				return "listAuthLog";
			else
				return "failure";
		} catch (Exception e) {
			log.error(e);
			return "failure";
		}
	}
	
	public String list() {
		return "list";
	}

	public String failure() {
		return "failure";
	}

}
